/*
 ==============================================================================
 
 JUCE library : Starting point code, v1.26
 Copyright 2005 by Julian Storer. [edited by haydxn, 3rd April 2007]
 Modified 2008 by David Rowland
 
 This is a modified base application project that uses the recent Juce cocoa code
 It is split into separate cpp and h files and uses some preprocessor macros
 
 ==============================================================================
 */
#ifndef _MAINCOMPONENT_H_
#define _MAINCOMPONENT_H_

#include <juce/juce.h>
#include "AudioFilePlayer.h"

class MainComponent  :	public Component,
						public AudioIODeviceCallback,
						public ButtonListener,
						public ChangeListener
{
private:
	//==============================================================================
	TextButton* startButton;
	TextButton* pauseButton;
	TextButton* stopButton;
	TextButton* audioSettingButton;
	
	Label* tracksPlayedLabel;
	Slider* tracksToPlaySlider;
	
	Slider* distanceSlider;
	
	AudioDeviceManager audioDeviceManager;
	AudioSourcePlayer audioSourcePlayer;
	MixerAudioSource mixerSource;
//	OwnedArray<AudioFilePlayer> filePlayers;
	OwnedArray< OwnedArray<AudioFilePlayer> > filePlayers;
	OwnedArray<File> audioFiles;
	
	// counters used throught the app
	int currentTrack;
	int currentArtist;
	int tracksPlayed;
	
	// this flag is used to make sure the the audio callback doesn't
	// interate through all the buttons if we select a new one
	bool buttonJustPressed;
	
	TooltipWindow tooltipWindow;
public:
	//==============================================================================
	MainComponent ();
	
	~MainComponent ();
	
	//==============================================================================
	void resized ();
	
	void paint (Graphics& g);
	
	void repaint();
	//==============================================================================
	
	void buttonClicked (Button* clickedButton);
	
	void changeListenerCallback(void* pointer);
	
	void audioDeviceIOCallback (const float** inputChannelData,
								int totalNumInputChannels,
								float** outputChannelData,
								int totalNumOutputChannels,
								int numSamples);
	
	void audioDeviceAboutToStart (AudioIODevice* device);
	
	void audioDeviceStopped();
};

#endif//_MAINCOMPONENT_H_ 